<?php
class CrudController extends TextboxWidgetAppController {
    public $uses = array('Widget');
    public $components = array('Session');

    public function View($id) {
		$widget = $this->Widget->findById($id);
        $this->set('widget', $widget);
        $this->layout = false;
    }

    public function Add() {
        //set whatever data is required to build the page;
        //be sure this is done before instantiating the View class so all
        //set variables are passed when you pass this controller object in the constructor
        $this->layout = false;
        if ($this->request->is('post')) {
            $this->Widget->create();
            $this->request->data['Widget']['name'] = 'Textbox';
            if ($this->Widget->save($this->request->data)) {
                $this->Session->setFlash(__('Your widget has been saved.'));
            }
            $this->Session->setFlash(__('Unable to add your widget.'));
            $this->set('widget', $this->request->data);
            $this->render('view');
        }
		return $this->render('add');
    }
}